<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
	<script type="text/javascript">
		$(function() {
			$('#dg_doctorinfo').datagrid({
				singleSelect : false, //设置datagrid为单选
				url : 'doctor/querybyform', //为datagrid设置数据源
				//pagination : true, //启用分页
				//pageSize : 10, //设置初始每页记录数（页大小）
				//pageList : [ 10, 15, 20 ], //设置可供选择的页大小
				rownumbers : true, //显示行号
				fit : true, //设置自适应		
				header : '#searchtb_doctorinfo', //为datagrid标头添加搜索栏
				toolbar : '#tb_doctorinfo', //为datagrid添加工具栏
				columns : [ [ { //编辑datagrid的列
					title : '序号',
					field : 'no',
					align : 'center',
					checkbox : true
				}, {
					field : 'doctorno',
					title : '医生编号',
					width : 80
				}, {
					field : 'doctorname',
					title : '医生姓名',
					align : 'center',
					width : 80
				}, {
					field : 'cost',
					title : '医生诊金',
					align : 'center',
					width : 80
				}, {
					field : 'department',
					title : '医生科室',

					width : 100
				} ] ]
			});
		});
		function searchDoctor() {
			var search_doctorname = $('#search_doctorname').textbox("getValue");
			var search_doctorno = $('#search_doctorno').textbox("getValue");
			var search_department = $('#search_department').textbox("getValue");
		

			$("#dg_doctorinfo").datagrid('load', {
				"doctorno" : search_doctorno,
				"doctorname" : search_doctorname,
				"department" : search_department

			});
		}
		
		function addDoctor() {
			$('#dlg_doctorinfo').dialog('open').dialog('setTitle', '新增医生信息');		
			$('#ff_doctorinfo').form('clear');
			urls = 'doctor/adddoctor';
		}
		//保存信息
		function saveDoctorinfo() {
			$("#ff_doctorinfo").form("submit", {
				url : urls, //使用参数				
				success : function(result) {
					var result = eval('(' + result + ')');
					if (result.success == 'true') {
						$("#dg_doctorinfo").datagrid("reload");
						$("#dlg_doctorinfo").dialog("close");
					}
					$.messager.show({
						title : "提示信息",
						msg : result.message
					});
				}
			});
		}
		
		function deleteDoctor() {

			var row = $("#dg_doctorinfo").datagrid("getSelected");
			var rows = $("#dg_doctorinfo").datagrid('getSelections');
			if (rows.length > 0) {
				var row = $("#dg_doctorinfo").datagrid("getSelected");
				if (row) {
					$('#dlg_deletedctorinfo').dialog('open').dialog('setTitle',
							'删除医生药品');
					$("#ff_deletedoctorinfo").form("load", {

						"doctorno" : row.doctorno,
						"doctorname" : row.doctorname,

					});
					urls = "doctor/deletedoctor";
				}
			} else {
				$.messager.alert('提示', '请选择要删除的行', 'info');
			}

		}
		function deleteDoctorDlg() {
			$("#ff_deletedoctorinfo").form("submit", {
				url : urls, //使用参数				
				success : function(result) {
					var result = eval('(' + result + ')');
					if (result.success == 'true') {
						$("#dg_doctorinfo").datagrid("reload");
						$("#dlg_deletedctorinfo").dialog("close");
					}
					$.messager.show({
						title : "提示信息",
						msg : result.message
					});
				}
			});
		}
		
	</script>

	<table id="dg_doctorinfo" class="easyui-datagrid"></table>
	<!-- 创建查询工具栏 -->
	<div id="searchtb_doctorinfo" style="padding: 2px 5px;">
		<form id="searchForm_doctorinfo" method="post">
			<div style="padding: 3px">
				科室&nbsp;&nbsp;<input class="easyui-textbox" name="department"
					id="search_department" style="width: 110px" />&nbsp;医生编号&nbsp;&nbsp;<input
					class="easyui-textbox" name="id" id="search_doctorno"
					style="width: 70px" />
			</div>
			<div style="padding: 3px">
				姓名&nbsp;&nbsp;<input class="easyui-textbox" name="name"
					id="search_doctorname" style="width: 110px" /> &nbsp;&nbsp;<a
					href="javascript:void(0)" class="easyui-linkbutton"
					iconCls="icon-search" plain="true" onclick="searchDoctor();">查找</a>
			</div>
		</form>
	</div>
	<div id="tb_doctorinfo" style="padding: 2px 5px;">
		<a href="javascript:void(0)" class="easyui-linkbutton"
			iconCls="icon-add" plain="true" onclick="addDoctor();">添加</a>  <a
			href="javascript:void(0)" class="easyui-linkbutton"
			iconCls="icon-remove" onclick="deleteDoctor();" plain="true">删除</a>
	</div>
	
	<div id="dlg_doctorinfo" class="easyui-dialog" title="添加医生" closed="true"
		style="width: 500px;">
		<div style="padding: 10px 60px 20px 60px">
			<form id="ff_doctorinfo" method="POST" action="">
				<table cellpadding="5">

					<tr>
						<td>医生姓名:</td>
						<td><input class="easyui-textbox" type="text" id="doctorname"
							name="doctorname" data-options="required:true"></input></td>
					</tr>
					<tr>
						<td>医生编号:</td>
						<td><input class="easyui-textbox" type="text" id="doctorno"
							name="doctorno" data-options="required:true"></input></td>
					</tr>

					<tr>
						<td>医生诊金:</td>
						<td><input class="easyui-textbox" type="text"
							id="cost" name="cost"
							data-options="required:true"></input></td>
					</tr>					
					<tr>
						<td>医生科室:</td>
						<td><input class="easyui-textbox" type="text" id="department"
							name="department" data-options="required:true"></input></td>
					</tr>
					

				</table>
			</form>
			<div style="text-align: center; padding: 5px">
				<a href="javascript:void(0)" class="easyui-linkbutton"
					onclick="saveDoctorinfo();">保存</a> <a href="javascript:void(0)"
					class="easyui-linkbutton" onclick="clearForm();">清空</a>
			</div>
		</div>
		
		<div id="dlg_deletedctorinfo" class="easyui-dialog" title="删除医生"
		closed="true" style="width: 500px;">
		<div style="padding: 10px 60px 20px 60px">
			<div style="text-align: center; padding: 5px">
				确定要删除药品？<br>
				<form id="ff_deletedoctorinfo" method="POST" action="">
					<tr>
						<td>医生编号:</td>
						<td><input class="easyui-textbox" type="text" id="doctorno"
							name="doctorno" data-options="required:true" readonly="readonly"
							style="width: 100%;"></input></td>
					</tr>
					<tr>
						<td>医生姓名:</td>
						<td><input class="easyui-textbox" type="text" id="doctorname"
							name="doctorname" data-options="required:true" readonly="readonly"
							style="width: 100%;"></input></td>
					</tr>
				</form>
				<a href="javascript:void(0)" class="easyui-linkbutton"
					onclick="deleteDoctorDlg();">删除</a>
			</div>
		</div>
	</div>
	</div>
</body>
</html>